package top.toptimus.dto.order.orderCache;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import top.toptimus.dto.style.StyleWithUnitConsumptionIndexDTO;
import top.toptimus.util.ValueUtil;

/**
 * 订单面料耗用DTO
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class OrderFabricUnitConsumptionDTO {
    private String refStyleId;//参考款id
    private String styleNameCn;    //  款式名称
    private String styleCode;    //  编码
    private Double fabricMaxUnit;    //  款式面料最大单耗
    private Double fabircAverageUnit; //  款式面料平均单耗
    private Double fabricActualConsumption; //  面料实际单耗

    /**
     * @param styleWithUnitConsumptionIndexDTO 款式标准单耗
     * @param fabricActualConsumption          实际单耗
     */
    public OrderFabricUnitConsumptionDTO(
            StyleWithUnitConsumptionIndexDTO styleWithUnitConsumptionIndexDTO,
            Double fabricActualConsumption
    ) {
        this.refStyleId = styleWithUnitConsumptionIndexDTO.getId();
        this.styleNameCn = styleWithUnitConsumptionIndexDTO.getName();
        this.styleCode = styleWithUnitConsumptionIndexDTO.getCode();
        this.fabricMaxUnit = ValueUtil.DoubleNullValue(styleWithUnitConsumptionIndexDTO.getUnit());
        this.fabircAverageUnit = ValueUtil.DoubleNullValue(styleWithUnitConsumptionIndexDTO.getAverageUnit());
        this.fabricActualConsumption = fabricActualConsumption;
    }
}
